package com.lecture.java8.reflex.test;

import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;

/**
 * @author luyn
 * @description
 * @Date 2020/11/10 19:28
 * @Version 1.0
 */
public class DemoTestMain {
    public static void main(String[] args) {
        DemoTest demoTest = new DemoTest(1);
        Class c = demoTest.getClass();
        Constructor[] constructors;
        // 获取当前按类的所有构造方法
        constructors = c.getDeclaredConstructors();
        for (int i = 0; i < constructors.length; i++) {
            // 获取构造方法的类型
            System.out.println("构造方法类型：" + Modifier.toString(constructors[i].getModifiers()));
            // 获取构造方法的参数类型
            Class[] parameterTypes = constructors[i].getParameterTypes();
            System.out.print("构造方法参数类型：");
            for (int i1 = 0; i1 < parameterTypes.length; i1++) {
                System.out.print(parameterTypes[i1].getName() + "\t");
            }
            System.out.println("\n");
        }
    }
}
